package cn.b.sky.mes.em.model;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

import cn.b.sky.common.model.ImeCommon;

/**
 * 
 * <strong>Title : ProductionResults.java<br>
 * </strong> <strong>Package : cn.b.sky.mes.em.model<br>
 * </strong> <strong>Description : </strong>生产实绩实体<br>
 * <strong>Create on : 2015-11-19 下午02:53:52<br>
 * </strong>
 * <p>
 * 
 * @author zhaoxin01<br>
 * @version <strong>v1.0.0</strong><br>
 *          <br>
 *          <strong>修改历史:</strong><br>
 *          修改人 | 修改日期 | 修改描述<br>
 *          -------------------------------------------<br>
 *          <br>
 *          <br>
 */
public class ProductionResults extends ImeCommon implements Comparable<ProductionResults> {
  /**
   * 设备编号:nvarchar2(20)
   */
  private String equipmentCode;

  private String equipmentText;

  /**
   * 日期:date(0)
   */
  @DateTimeFormat(iso = ISO.DATE_TIME, pattern = "yyyy-MM-dd")
  private Date theDate;

  /**
   * 计划时长（分钟）:number(0)
   */
  private Long scheduledTime;

  private Long downTime;// 停机时长

  private Long goodParts;// 良品数量

  private Long defectiveParts;// 不良品数量

  private Double cycleTime;// 周期时间

  private Double oee;// oee值

  private Double availableRate;// 可用率

  private Double performanceRate;// 表现率

  private Double qualityRate;// 良品率

  private String warn;

  private String availableRateWarn;// 可用率异常信息

  private String performanceRateWarn;// 表现率异常信息

  private String qualityRateWarn;// 良品率异常信息

  private String oeeWarn;

  private String json;

  public String getJson() {
    json = "{" + "'equipmentCode':'" + equipmentCode + "','oee':'" + oee + "','availableRate':'" + availableRate
        + "','performanceRate':'" + performanceRate + "','qualityRate':'" + qualityRate + "','availableRateWarn':'"
        + availableRateWarn + "','performanceRateWarn':'" + performanceRateWarn + "','qualityRateWarn':'"
        + qualityRateWarn + "','oeeWarn':'" + oeeWarn + "'}";
    return json;
  }

  public void setJson(String json) {
    this.json = json;
  }

  public String getEquipmentCode() {
    return equipmentCode;
  }

  public void setEquipmentCode(String equipmentCode) {
    this.equipmentCode = equipmentCode;
  }

  public String getEquipmentText() {
    return equipmentText;
  }

  public void setEquipmentText(String equipmentText) {
    this.equipmentText = equipmentText;
  }

  public Date getTheDate() {
    return theDate;
  }

  public void setTheDate(Date theDate) {
    this.theDate = theDate;
  }

  public Long getScheduledTime() {
    return scheduledTime;
  }

  public void setScheduledTime(Long scheduledTime) {
    this.scheduledTime = scheduledTime;
  }

  public Long getDownTime() {
    return downTime;
  }

  public void setDownTime(Long downTime) {
    this.downTime = downTime;
  }

  public Long getGoodParts() {
    return goodParts;
  }

  public void setGoodParts(Long goodParts) {
    this.goodParts = goodParts;
  }

  public Long getDefectiveParts() {
    return defectiveParts;
  }

  public void setDefectiveParts(Long defectiveParts) {
    this.defectiveParts = defectiveParts;
  }

  public Double getOee() {
    return oee;
  }

  public void setOee(Double oee) {
    this.oee = oee;
  }

  public Double getAvailableRate() {
    return availableRate;
  }

  public void setAvailableRate(Double availableRate) {
    this.availableRate = availableRate;
  }

  public Double getPerformanceRate() {
    return performanceRate;
  }

  public void setPerformanceRate(Double performanceRate) {
    this.performanceRate = performanceRate;
  }

  public Double getQualityRate() {
    return qualityRate;
  }

  public void setQualityRate(Double qualityRate) {
    this.qualityRate = qualityRate;
  }

  public Double getCycleTime() {
    return cycleTime;
  }

  public void setCycleTime(Double cycleTime) {
    this.cycleTime = cycleTime;
  }

  public String getWarn() {
    return warn;
  }

  public void setWarn(String warn) {
    this.warn = warn;
  }

  public String getAvailableRateWarn() {
    return availableRateWarn;
  }

  public void setAvailableRateWarn(String availableRateWarn) {
    this.availableRateWarn = availableRateWarn;
  }

  public String getPerformanceRateWarn() {
    return performanceRateWarn;
  }

  public void setPerformanceRateWarn(String performanceRateWarn) {
    this.performanceRateWarn = performanceRateWarn;
  }

  public String getQualityRateWarn() {
    return qualityRateWarn;
  }

  public void setQualityRateWarn(String qualityRateWarn) {
    this.qualityRateWarn = qualityRateWarn;
  }

  public String getOeeWarn() {
    return oeeWarn;
  }

  public void setOeeWarn(String oeeWarn) {
    this.oeeWarn = oeeWarn;
  }

  @Override
  public int compareTo(ProductionResults o) {
    if (this.oee == null) {
      return 1;
    } else if (o.getOee() == null) {
      return -1;
    } else {
      return this.oee.compareTo(o.getOee());
    }
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((availableRate == null) ? 0 : availableRate.hashCode());
    result = prime * result + ((availableRateWarn == null) ? 0 : availableRateWarn.hashCode());
    result = prime * result + ((cycleTime == null) ? 0 : cycleTime.hashCode());
    result = prime * result + ((defectiveParts == null) ? 0 : defectiveParts.hashCode());
    result = prime * result + ((downTime == null) ? 0 : downTime.hashCode());
    result = prime * result + ((equipmentCode == null) ? 0 : equipmentCode.hashCode());
    result = prime * result + ((equipmentText == null) ? 0 : equipmentText.hashCode());
    result = prime * result + ((goodParts == null) ? 0 : goodParts.hashCode());
    result = prime * result + ((json == null) ? 0 : json.hashCode());
    result = prime * result + ((oee == null) ? 0 : oee.hashCode());
    result = prime * result + ((oeeWarn == null) ? 0 : oeeWarn.hashCode());
    result = prime * result + ((performanceRate == null) ? 0 : performanceRate.hashCode());
    result = prime * result + ((performanceRateWarn == null) ? 0 : performanceRateWarn.hashCode());
    result = prime * result + ((qualityRate == null) ? 0 : qualityRate.hashCode());
    result = prime * result + ((qualityRateWarn == null) ? 0 : qualityRateWarn.hashCode());
    result = prime * result + ((scheduledTime == null) ? 0 : scheduledTime.hashCode());
    result = prime * result + ((theDate == null) ? 0 : theDate.hashCode());
    result = prime * result + ((warn == null) ? 0 : warn.hashCode());
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    ProductionResults other = (ProductionResults) obj;
    if (availableRate == null) {
      if (other.availableRate != null) {
        return false;
      }
    } else if (!availableRate.equals(other.availableRate)) {
      return false;
    }
    if (availableRateWarn == null) {
      if (other.availableRateWarn != null) {
        return false;
      }
    } else if (!availableRateWarn.equals(other.availableRateWarn)) {
      return false;
    }
    if (cycleTime == null) {
      if (other.cycleTime != null) {
        return false;
      }
    } else if (!cycleTime.equals(other.cycleTime)) {
      return false;
    }
    if (defectiveParts == null) {
      if (other.defectiveParts != null) {
        return false;
      }
    } else if (!defectiveParts.equals(other.defectiveParts)) {
      return false;
    }
    if (downTime == null) {
      if (other.downTime != null) {
        return false;
      }
    } else if (!downTime.equals(other.downTime)) {
      return false;
    }
    if (equipmentCode == null) {
      if (other.equipmentCode != null) {
        return false;
      }
    } else if (!equipmentCode.equals(other.equipmentCode)) {
      return false;
    }
    if (equipmentText == null) {
      if (other.equipmentText != null) {
        return false;
      }
    } else if (!equipmentText.equals(other.equipmentText)) {
      return false;
    }
    if (goodParts == null) {
      if (other.goodParts != null) {
        return false;
      }
    } else if (!goodParts.equals(other.goodParts)) {
      return false;
    }
    if (json == null) {
      if (other.json != null) {
        return false;
      }
    } else if (!json.equals(other.json)) {
      return false;
    }
    if (oee == null) {
      if (other.oee != null) {
        return false;
      }
    } else if (!oee.equals(other.oee)) {
      return false;
    }
    if (oeeWarn == null) {
      if (other.oeeWarn != null) {
        return false;
      }
    } else if (!oeeWarn.equals(other.oeeWarn)) {
      return false;
    }
    if (performanceRate == null) {
      if (other.performanceRate != null) {
        return false;
      }
    } else if (!performanceRate.equals(other.performanceRate)) {
      return false;
    }
    if (performanceRateWarn == null) {
      if (other.performanceRateWarn != null) {
        return false;
      }
    } else if (!performanceRateWarn.equals(other.performanceRateWarn)) {
      return false;
    }
    if (qualityRate == null) {
      if (other.qualityRate != null) {
        return false;
      }
    } else if (!qualityRate.equals(other.qualityRate)) {
      return false;
    }
    if (qualityRateWarn == null) {
      if (other.qualityRateWarn != null) {
        return false;
      }
    } else if (!qualityRateWarn.equals(other.qualityRateWarn)) {
      return false;
    }
    if (scheduledTime == null) {
      if (other.scheduledTime != null) {
        return false;
      }
    } else if (!scheduledTime.equals(other.scheduledTime)) {
      return false;
    }
    if (theDate == null) {
      if (other.theDate != null) {
        return false;
      }
    } else if (!theDate.equals(other.theDate)) {
      return false;
    }
    if (warn == null) {
      if (other.warn != null) {
        return false;
      }
    } else if (!warn.equals(other.warn)) {
      return false;
    }
    return true;
  }

}
